class Solution:
    def get_path(self, maze):
        if not maze:
            return None
        path = []
        failed_points = set()
        self.recur_get_path(maze, len(maze) - 1, len(maze[0]) - 1, path, failed_points)
        return path

    def recur_get_path(self, maze, r, c, path, failed_points):
        if r < 0 or c < 0 or not maze[r][c]:
            return False
        point = (r, c)
        if point in failed_points:
            return False
        if (r == 0 and c == 0) or self.recur_get_path(maze, r - 1, c, path, failed_points) \
                or self.recur_get_path(maze, r, c - 1, path, failed_points):
            path.append(point)
            return True
        failed_points.add(point)
        return False


maze = [[True, True, True, True, True],
        [True, False, True, False, False],
        [True, True, True, False, True],
        [True, True, True, True, True, ]]

solution = Solution()
res = solution.get_path(maze)
print(res)
